//
//  TGVisitorViewController.swift
//  TGWeiBo
//
//  Created by 涛哥无敌威武 on 16/4/17.
//  Copyright © 2016年 taoge. All rights reserved.
//

import UIKit

class TGVisitorViewController: UITableViewController {
    
    //判断用户是否登录
    var isLogin:Bool = false
    //访客视图
    var visitorView:TGVisitorView?
    
    override func loadView() {
        //三目运算判断该加载哪一个页面
        isLogin ? super.loadView() : setUpVisitorView()
    }
    
    

    override func viewDidLoad() {
        super.viewDidLoad()
       }
    
     //MARK: - 监听方法
   @objc private func login(){
        
        let oauthVC = TGOAuthViewController()
        presentViewController(UINavigationController(rootViewController: oauthVC), animated: true, completion: nil)
        
    }
    
    
    //MARK: 导航栏相关设置
    private func setUpNav(){
    
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
        
        }
    
    
    //MARK: 设置视图
    private func setUpVisitorView(){
    
        setUpNav()
        visitorView = TGVisitorView()
        visitorView?.visitorClosure = {
        self.login()
        
        }
        view = visitorView
    
    
    }
    

}